﻿using System.Drawing;
using HtmlTextsLength.Sources.OriginText;

var test1 = "In fact, I could ha";
var test2 = " class without using a concise constructor";
var size1 = 582;
var size2 = 1388;
var font = new FontResource();
Console.WriteLine(font.GetWidthOfString(test1,36));
Console.WriteLine(font.GetWidthOfString(test2,36));
// Console.WriteLine(clawidth(test1,36));
// Console.WriteLine(clawidth("a",36));//19.9
// Console.WriteLine(clawidth(Maker("a"), 36));
// Console.WriteLine(clawidth("b",36));//22.99
// Console.WriteLine(clawidth(Maker("b",100),36));
// Console.WriteLine(clawidth("aa",36)-clawidth("a",36));
// Console.WriteLine(clawidth("bb",36)-clawidth("b",36));

string Maker(string str, int time=100)
{
    return string.Concat(Enumerable.Repeat(str, time));
}
// 忽略font-style/font-weight
double clawidth(string text,double fs)
{
    Font font = new Font("Microsoft YaHei", (float)fs, FontStyle.Regular, GraphicsUnit.Pixel);

    using var graphics = Graphics.FromImage(new Bitmap(1, 1));
    var size = graphics.MeasureString(text, font);
    var width = size.Width;
    return width;
}